package com.example.demo.controller;

import com.example.demo.model.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class PageController {
    private final static String indexPage = "index";
    private final static String indexUrl="/";
    private final static String generatePage = "generatePage";
    private final static String generateUrl="/generate";
    private final static String adminPage = "adminPage";
    private final static String adminUrl="/admin";
    @Autowired
    private NoticeService service;
    @GetMapping(generateUrl)
    public String getGeneratePage(HttpServletRequest request)
    {
        request.setAttribute("notice",service.getNotice());
        return generatePage;
    }
    @GetMapping(adminUrl)
    public String getAdminPage(HttpServletRequest request)
    {
        request.setAttribute("notice",service.getNotice());
        return adminPage;
    }
    @GetMapping(indexUrl)
    public String getIndexPage()
    {
        return indexPage;
    }
}
